package Options::UserSync::API::CountriesConverter;
use strict;

sub new
{
    my $class = $_[0];
    my $self;
    my %Countries = (                                       
					  'AFR'					=> '',      #Africa               
					  'ALB'					=> '008',      #Albania              
					  'ALGE'				=> '012',      #Algeria              
					  'ANDO'				=> '020',      #Andorra              
					  'ARGE'				=> '032',      #Argentina            
					  'AUS'				        => '040',      #Austria              
					  'AUST'				=> '036',      #Australia            
					  'AZER'				=> '031',      #Azerbaijan           
					  'BAH'				        => '048',      #Bahrain              
					  'BAHA'				=> '044',      #Bahamas              
					  'BANG'				=> '050',      #Bangladesh           
					  'BARB'				=> '052',      #Barbados             
					  'BELG'				=> '056',      #Belgium              
					  'BELI'				=> '084',      #Belize               
					  'BERM'				=> '060',      #Bermuda              
					  'BOLI'				=> '068',      #Bolivia              
					  'BOSN'				=> '070',      #Bosnia-Herzegovina   
					  'BOTS'				=> '072',      #Botswana             
					  'BRAZ'				=> '076',      #Brazil               
					  'BULG'				=> '100',      #Bulgaria             
					  'BURK'				=> '854',      #Burkina Faso         
					  'CAMB'				=> '116',      #Cambodia             
					  'CAME'				=> '120',      #Cameroon             
					  'CAN'				        => '',      #Canary Islands       
					  'CANA'				=> '124',      #Canada               
					  'CHAN'	=> '826',      				#Channel Islands      
					  'CHIL'				=> '152',      #Chile                
					  'CHIN'				=> '156',      #China                
					  'COLO'				=> '170',      #Colombia             
					  'COLU'				=> '',      #Columbia             
					  'CROA'				=> '191',      #Croatia              
					  'CYPR'				=> '196',      #Cyprus               
					  'CZEC'				=> '203',      #Czech Republic       
					  'DENM'				=> '208',      #Denmark              
					  'DOM'				        => '214',      #Dominican Republic   
					  'EGYP'				=> '818',      #Egypt                
					  'EIRE'				=> '372',      #Eire                 
					  'ELS'				        => '222',      #El Salvador          
					  'ETH'				        => '231',      #Ethiopia             
					  'EUCA'				=> '218',      #Ecuador              
					  'FALK'				=> '238',      #Falkland Islands     
					  'FARO'				=> '234',      #Faroe Islands        
					  'FIJ'				        => '242',      #Fiji                 
					  'FINL'				=> '246',      #Finland              
					  'FRAN'				=> '250',      #France               
					  'GEOR'				=> '268',      #Georgia              
					  'GERM'				=> '276',      #Germany              
					  'GHAN'				=> '288',      #Ghana                
					  'GIB'				        => '292',      #Gibraltar            
					  'GREE'				=> '300',      #Greece               
					  'GRNL'				=> '304',      #Greenland            
					  'GUYA'				=> '328',      #Guyana               
					  'HOLL'				=> '528',      #Holland              
					  'HON'				        => '340',      #Honduras             
					  'HONG'				=> '344',      #Hong Kong            
					  'HUNG'				=> '348',      #Hungary              
					  'ICEL'				=> '352',      #Iceland              
					  'INDI'				=> '356',      #India                
					  'INDO'				=> '360',      #Indonesia            
					  'IRAN'				=> '364',      #Iran                 
					  'IRAQ'				=> '368',      #Iraq                 
					  'ISL'		=> '826',    					#Isle Of Man          
					  'ISRA'				=> '376',      #Israel               
					  'ITAL'				=> '380',      #Italy                
					  'IVOR'				=> '384',      #Ivory Coast          
					  'JAMA'				=> '388',      #Jamaica              
					  'JAPA'				=> '392',      #Japan                
					  'JORD'				=> '400',      #Jordan               
					  'KAZA'				=> '398',      #Kazakhstan           
					  'KENY'				=> '404',      #Kenya                
					  'KORE'				=> '410',      #Korea                
					  'KUW'				  => '414',      #Kuwait               
					  'LAOS'				=> '418',      #Laos                 
					  'LAT'				  => '428',      #Latvia               
					  'LEBA'				=> '422',      #Lebanon              
					  'LIB'				  => '434',      #Libya                
					  'LITH'				=> '440',      #Lithuania            
					  'LUX'				  => '442',      #Luxembourg           
					  'MADA'				=> '450',      #Madagascar           
					  'MAL'				  => '458',      #Malaysia             
					  'MALA'				=> '454',      #Malawi               
					  'MALD'				=> '462',      #Maldives             
					  'MALI'				=> '466',      #Mali                 
					  'MALT'				=> '470',      #Malta                
					  'MAU'				  => '480',      #Mauritius            
					  'MEXI'				=> '484',      #Mexico               
					  'MONA'				=> '492',      #Monaco               
					  'MORO'				=> '504',      #Morocco              
					  'MOZA'				=> '508',      #Mozambique           
					  'NAMI'				=> '516',      #Namibia              
					  'NCYP'				=> '196',      #Northern Cyprus      
					  'NETH'				=> '528',      #Netherlands          
					  'NEW'				  => '540',      #New Caledonia        
					  'NIGE'				=> '566',      #Nigeria              
					  'NIRE'	=> '826',      				#Northern Ireland     
					  'NORW'				=> '578',      #Norway               
					  'NZ'				  => '554',      #New Zealand          
					  'OMA'				  => '512',      #Oman                 
					  'PAKI'				=> '586',      #Pakistan             
					  'PANA'				=> '591',      #Republic of Panama   
					  'PAPU'				=> '598',      #Papua New Guinea     
					  'PERU'				=> '604',      #Peru                 
					  'PHIL'				=> '608',      #Philippines          
					  'POLA'				=> '616',      #Poland               
					  'POLY'				=> '258',      #Polynesia            
					  'PORT'				=> '620',      #Portugal             
					  'PUER'				=> '630',      #Puerto Rico          
					  'QAT'				  => '634',      #Qatar                
					  'R.O.'				=> '158',      #R.O.C                
					  'REU'				  => '638',      #Reunion Island       
					  'ROMA'				=> '642',      #Romania              
					  'RUSS'				=> '643',      #Russia               
					  'RWAN'				=> '646',      #Rwanda               
					  'SAUD'				=> '682',      #Saudia Arabia        
					  'SCIL'	=> '826',      #Isles of Scilly      
					  'SCOT'	=> '826',      #Scottish Highlands & Islands
					  'SENE'				=> '686',      #Senegal              
					  'SERB'				=> '688',      #Serbia               
					  'SING'				=> '702',      #Singapore            
					  'SLO'				        => '703',      #Slovakia             
					  'SLOV'				=> '705',      #Slovenia             
					  'SOLO'				=> '090',      #Soloman Island       
					  'SOUT'				=> '710',      #South Africa         
					  'SPA'				        => '724',      #Spain                
					  'SRI'				        => '144',      #Sri Lanka            
					  'SUDA'				=> '736',      #Sudan                
					  'SWED'				=> '752',      #Sweden               
					  'SWIT'				=> '756',      #Switzerland          
					  'SYRI'				=> '760',      #Syria                
					  'TAI'				        => '158',      #Taiwan               
					  'TANZ'				=> '834',      #Tanzania             
					  'THAI'				=> '764',      #Thailand             
					  'TRIN'				=> '780',      #Trinidad & Tobago    
					  'TUNI'				=> '788',      #Tunisia              
					  'TURK'				=> '792',      #Turkey               
					  'UAE'				        => '784',      #United Arab Emirates 
					  'UGAN'				=> '800',      #Uganda               
					  'UK'		=> '826',      #United Kingdom       
					  'UKR'				        => '804',      #Ukraine              
					  'UNIT'	=> '826',      #Great Britain        
					  'USA'				        => '840',      #USA                  
					  'VENE'				=> '862',      #Venezuela            
					  'VIET'				=> '704',      #Vietnam              
					  'WIND'				=> '388',      #West Indies          
					  'YEM'				        => '887',      #Rep Of Yemen         
					  'YUGO'				=> '',         #Yugoslavia           
					  'ZAMB'				=> '894',      #Zambia               
					  'ZIMB'				=> '716',      #Zimbabwe        
		);
    $self->{_countriesTranslation} = \%Countries;
    bless $self, $class;
    return $self;
}

sub validateBFCountryName {
		my $self = shift;
                my $name = shift;
                if (defined($self->{_countriesTranslation}->{$name}) && $self->{_countriesTranslation}->{$name} ne "") {
                    return 1;
                } else {
                    return 0;
                }
}

sub validateCountryISO {
		my $self = shift;
                my $iso = shift;
                while( my ($k, $v) = each %{$self->{_countriesTranslation}} ) {
                    if($v eq $iso) {
                       return 1; 
                    }
                }
                return 0;
}

sub getCountryISOByBFName {
		my $self = shift;
                my $name = shift;
                return $self->{_countriesTranslation}->{$name};
}

sub getBFNameByCountryISO {
		my $self = shift;
                my $iso = shift;
                if ($iso eq '826') {
                    return "UK";
                } else {
                    while( my ($k, $v) = each %{$self->{_countriesTranslation}} ) {
                        if($v eq $iso) {
                           return $k; 
                        }
                    }
                }
}

1;
